home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / obj2asm.zip / OUSTRUCT.C < prev    next >
Text File  |  1991-10-01  |  1KB  |  45 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "o.h"
  4.  
  5. int struc_compare( STRUC_T *, STRUC_T * );
  6.  
  7. int struc_compare( rec_1, rec_2 )
  8.     STRUC_T *rec_1;
  9.     STRUC_T *rec_2;
  10. {
  11.     int     result;
  12.  
  13.     result = strcmp(rec_1->form, rec_2->form);
  14.  
  15.     if ( result == 1 ) {
  16.         result = LEFT;
  17.     } else {
  18.         if ( result == 0 ) {
  19.             return( EQUAL );
  20.         } else {
  21.             return( RIGHT );
  22.         }
  23.     }
  24.     return( LEFT );     /* ;* */
  25. }
  26.  
  27. STRUC_T *struc_insert( form )
  28.     char    *form;
  29. {
  30.     STRUC_T *struc_rec;
  31.     NODE_T  *struc_node;
  32.     char    *form_copy;
  33.     int     length;
  34.  
  35.     struc_rec = (STRUC_T *)o_malloc( sizeof(STRUC_T) );
  36.     length = strlen(form) + 1;
  37.     form_copy = (char *)o_malloc( length );
  38.     strcpy( form_copy, form );
  39.     struc_rec->form  = form_copy;
  40.     struc_rec->index = 0;               /* Not determined yet */
  41.  
  42.     struc_node = insert( (char *)struc_rec, struc_tree, TC struc_compare );
  43.     return( (STRUC_T *)struc_node->data );
  44. }
  45.